import { Button } from 'antd';
import { ColumnsRenderFun, DictionaryRenderFun, DictionaryRenderFuns } from '../../Acommon';
import { DeleteOutlined, PlusCircleOutlined } from '@ant-design/icons';

/**
 * @SelectExpertsColumns 弹窗专家表格配置列表
 * @returns
 */
export const getSelectExpertsColumns = (): Record<string, any>[] => {
  return [
    {
      title: '序号',
      dataIndex: 'index',
      key: 'index',
      visible: true,
      width: 50,
      fixed: 'left',
      render: (_: string, __: Record<string, any>, index: string) => index + 1,
    },
    {
      title: '姓名',
      dataIndex: 'fullName',
      key: 'fullName',
      visible: true,
      width: 80,
      render: (text: string) => ColumnsRenderFun({ text, isTooltip: true }),
    },
    {
      title: '所在单位',
      dataIndex: 'companyName',
      key: 'companyName',
      visible: true,
      width: 100,
      render: (text: string) => ColumnsRenderFun({ text, isTooltip: true }),
    },
    {
      title: '从事专业',
      dataIndex: 'industryTypeName',
      key: 'industryTypeName',
      visible: true,
      width: 140,
      render: (text: string) => DictionaryRenderFuns({ text, isTooltip: true, wordNum: 100 }),
    },
    {
      title: '职称',
      dataIndex: 'rankTypeName',
      key: 'rankTypeName',
      visible: true,
      width: 100,
      render: (text: string) => DictionaryRenderFun({ text, isTooltip: true }),
    },
    {
      title: '身份证号码',
      dataIndex: 'cardNum',
      key: 'cardNum',
      visible: true,
      width: 100,
      render: (text: string) => ColumnsRenderFun({ text, isTooltip: true }),
    },
    {
      title: '联系电话',
      dataIndex: 'phoneMobile',
      key: 'phoneMobile',
      visible: true,
      width: 100,
      render: (text: string) => ColumnsRenderFun({ text, isTooltip: true }),
    },
  ];
};

/**
 * @getBidColumns 评标专家表格配置列表
 * @returns
 */
export const getExpertsColumns = ({ onRemove, onOpen, isShowOpenBtn }: any): Record<string, any>[] => {
  const columnsList = [
    {
      title: '序号',
      dataIndex: 'index',
      key: 'index',
      visible: true,
      width: 80,
      fixed: 'left',
      render: (_: string, __: Record<string, any>, index: string) => index + 1,
    },
    {
      title: '姓名',
      dataIndex: 'fullName',
      key: 'fullName',
      visible: true,
      width: 170,
      render: (text: string) => ColumnsRenderFun({ text }),
    },
    {
      title: '所在单位',
      dataIndex: 'companyName',
      key: 'companyName',
      visible: true,
      width: 170,
      render: (text: string) => ColumnsRenderFun({ text, isTooltip: true }),
    },
    {
      title: '职称',
      dataIndex: 'rankTypeName',
      key: 'rankTypeName',
      visible: true,
      width: 180,
      render: (text: string) => DictionaryRenderFun({ text, isTooltip: true }),
    },
    {
      title: '身份证号码',
      dataIndex: 'cardNum',
      key: 'cardNum',
      visible: true,
      width: 180,
      render: (text: string) => ColumnsRenderFun({ text, isTooltip: true }),
    },
    {
      title: '联系电话',
      dataIndex: 'phoneMobile',
      key: 'phoneMobile',
      visible: true,
      width: 180,
      render: (text: string) => ColumnsRenderFun({ text, isTooltip: true }),
    },
    {
      title: (
        <div style={{ textAlign: 'center' }}>
          <Button type={'link'} size={'small'} icon={<PlusCircleOutlined />} className="manageBtntTxtStyle" onClick={() => onOpen()}>
            选择
          </Button>
        </div>
      ),
      dataIndex: 'operation',
      key: 'operation',
      width: 100,
      visible: true,
      unDrag: true,
      align: 'left',
      fixed: 'right',
      render: (_: string, record: Record<string, any>, index: number) => {
        return (
          <div style={{ textAlign: 'center' }}>
            <Button
              type={'link'}
              size={'small'}
              danger
              className={'manageBtntTxtStyle manageColorRedBtn'}
              icon={<DeleteOutlined />}
              onClick={() => {
                onRemove(record, index);
              }}
            >
              删除
            </Button>
          </div>
        );
      },
    },
  ];

  if (isShowOpenBtn) {
    return columnsList;
  } else {
    return columnsList?.filter((item) => item?.key != 'operation');
  }
};

/**
 * @getBidColumns 采购人代表表格配置列表
 * @returns
 */
export const getBidColumns = ({ onRemove, onOpen, isShowOpenBtn }: any): Record<string, any>[] => {
  const columnsList = [
    {
      title: '序号',
      dataIndex: 'index',
      key: 'index',
      visible: true,
      width: 80,
      fixed: 'left',
      render: (_: string, __: Record<string, any>, index: string) => index + 1,
    },
    {
      title: '姓名',
      dataIndex: 'fullName',
      key: 'fullName',
      visible: true,
      width: 170,
      render: (text: string) => ColumnsRenderFun({ text }),
    },
    {
      title: '现任职务',
      dataIndex: 'positionName',
      key: 'positionName',
      visible: true,
      width: 170,
      render: (text: string) => ColumnsRenderFun({ text }),
    },
    {
      title: '联系电话',
      dataIndex: 'phoneMobile',
      key: 'phoneMobile',
      visible: true,
      width: 180,
      render: (text: string) => ColumnsRenderFun({ text }),
    },
    {
      title: '熟悉有关法规',
      dataIndex: 'lawFlag',
      key: 'lawFlag',
      visible: true,
      width: 180,
      render: (text: string) => {
        return (
          <>
            <span>{Number(text) == 0 ? '否' : Number(text) == 1 ? '是' : '--'}</span>
          </>
        );
      },
    },
    {
      title: '同类评标经历',
      dataIndex: 'experFlag',
      key: 'experFlag',
      visible: true,
      width: 180,
      render: (text: string) => {
        return (
          <>
            <span>{Number(text) == 0 ? '否' : Number(text) == 1 ? '是' : '--'}</span>
          </>
        );
      },
    },
    {
      title: '状态',
      dataIndex: 'stateName',
      key: 'stateName',
      visible: true,
      width: 180,
      render: (text: string) => DictionaryRenderFun({ text }),
    },
    // {
    //   title: (
    //     <div style={{ textAlign: 'center' }}>
    //       <Button
    //         type={'link'}
    //         size={'small'}
    //         icon={<PlusCircleOutlined />}
    //         className="manageBtntTxtStyle"
    //         onClick={() => onOpen()}
    //       >
    //         添加
    //       </Button>
    //     </div>
    //   ),
    //   dataIndex: 'operation',
    //   key: 'operation',
    //   width: 100,
    //   visible: true,
    //   unDrag: true,
    //   align: 'left',
    //   fixed: 'right',
    //   render: (_: string, Record: Record<string, any>, index: number) => {
    //     return (
    //       <div style={{ textAlign: 'center' }}>
    //         <Button
    //           type={'link'}
    //           size={'small'}
    //           danger
    //           className={'manageBtntTxtStyle manageColorRedBtn'}
    //           icon={<DeleteOutlined />}
    //           onClick={() => {
    //             onRemove(Record, index);
    //           }}
    //         >
    //           删除
    //         </Button>
    //       </div>
    //     );
    //   },
    // },
  ];

  if (isShowOpenBtn) {
    return columnsList;
  } else {
    return columnsList?.filter((item) => item?.key != 'operation');
  }
};
